﻿
using System ;
using System.Globalization ;


namespace MskEdit.Msk.Representation
{
    public class FloatField
    {
        private StringField stringField_ ;
        
        
        private FloatField( StringField stringField )
        {
            stringField_ = stringField ;
        }
                    
            
        public float? TryFrom( string line, float? fallbackValue ) { 
        
            string floatStr = stringField_.TryFrom( line, fallbackValue.ToString() ) ;
            
            float value = 0.0f ;            
            if ( ! float.TryParse( floatStr, NumberStyles.Any, CultureInfo.InvariantCulture, out value ) )
                return fallbackValue ;
            
            return value ;
        }

        
        static public FloatField AcadY   = new FloatField( StringField.AcadY ) ;
        static public FloatField AcadX   = new FloatField( StringField.AcadX ) ;
        static public FloatField AcadY2  = new FloatField( StringField.AcadY2 ) ;
        static public FloatField AcadX2  = new FloatField( StringField.AcadX2 ) ;
    }
}
